import request from '@/utils/request'

// 获取租约合同token
export function getToken() {
  return request({
    url: '/contract/charge/getToken',
    method: 'get',
  })
}

// 查询房产信息菜单列表
export function houseInfoPage(query) {
  return request({
    url: '/contract/charge/houseInfoPage',
    method: 'get',
    params: query
  })
}

// 查询省份列表
export function getBankAccountProvinceList() {
  return request({
    url: '/contract/charge/getBankAccountProvinceList',
    method: 'get',
  })
}

// 查询省份列表
export function getBankIdOptionList() {
  return request({
    url: '/contract/charge/getBankIdOptionList',
    method: 'get',
  })
}

// 获取持续时间
export function getChangeDuring(value) {
  return request({
    url: '/contract/charge/getChangeDuring',
    method: 'post',
    data: value,
  })
}

//获取付款单
export function getPaymentPlanList(value) {
  return request({
    url: '/contract/charge/getPaymentPlanList',
    method: 'post',
    data: value,
  })
}

//保存合同
export function saveContract(value) {
  return request({
    url: '/contract/charge/saveContract',
    method: 'post',
    data: value,
  })
}

//上传图片
export function upload(data, fileObj) {
  return request({
    url: '/contract/charge/upload',
    method: 'post',
    data: data,
    headers: {'Content-Type': 'multipart/form-data'},
    onUploadProgress: progressEvent => {
      const complete = (progressEvent.loaded / progressEvent.total * 100 | 0)
      fileObj.onProgress({percent: complete})     //调用upload组件的 onProgress
    }
  })
}

// 查询收房合同菜单列表
export function contractPage(query) {
  return request({
    url: '/contract/charge/contractPage',
    method: 'get',
    params: query
  })
}

